import scrapy
from scrapy.extensions.closespider import CloseSpider, NotConfigured
from scrapy.extensions.feedexport import FeedExporter
from scrapy.extensions.statsmailer import StatsMailer
from scrapy.extensions.httpcache import DbmCacheStorage, FilesystemCacheStorage
from scrapy.extensions.logstats import LogStats


base_url = 'http://c.biancheng.net'


class IplSpider(scrapy.Spider):
	name = 'ipl'
	# allowed_domains = []
	
	start_urls = ['http://c.biancheng.net/tensorflow/']
	
	def parse(self, response, **kwargs):
		links = response.css('.bg-f7f7f7 a')
		for link in links:
			name = link.css('::text').get()
			detail_url = base_url + link.attrib['href']
			print(name + " : " + detail_url)
			yield {
				'name': name,
				'detail_urls': detail_url
			}
